<?php
echo '<script type="text/javascript" src="'.base_url().'lib/jquery-1.9.0.js"></script>';
echo $ckeditor;
function find_parent($cat,$parent_id)
{
    if($parent_id == 0)
        return true;
    foreach($cat as $v)
    {
        if($v->id == $parent_id)
        {   
          return true;
        }
    }
    return false;
}
function recu($cat,$parent_id,$lv, $selected = null)
{
    foreach($cat as $v)
    {
        $s = $parent_id;
        $x = $lv;
        $sl = '';
        if(($v->parent_id == $parent_id) || !find_parent($cat,$v->parent_id))
        {
            $lv++;
            $i = 0;
            $str = '';
            while($i < $lv)
            {
                if(!$str)
                    $str = '|_';
                $str = '&nbsp&nbsp&nbsp'.$str;
                $i++;
            }
            if($v->id == $selected)
            $sl = 'selected';
            echo '<option value="'.$v->id.'" '.$sl.'>'.$str.$v->title.'</option>';
            $parent_id = $v->id;
            recu($cat,$parent_id,$lv,$selected);
        }
        $lv = $x;
        $parent_id = $s;
        //echo "<br />";
    }
}

?>
<script type="text/javascript">
function do_get(url)
{
    
    //alert(url);   
    /*$.get('http://localhost/notenews/index.php/news/geturl?url='+url, function(data){
        $('#webpage').html(data);
    });*/
    $.ajax({
        type:"GET",
        url:"http://localhost/notenews/index.php/news/geturl?url="+url,
        success: function(data){
            $('#webpage').html(data);
        }
    });
    
}

</script>
<body>
<div style="position: fixed; float: right; right: 5px; top: 5px;">
<form id="postpage" style="width: 400px;" method="post" action="<?php echo base_url().'index.php/news/postnews'?>">
<div style="float: left;">
    <label for="title"><strong>Title news</strong></label>
    <input style="width: 250px; height: 18px;" type="text" name="title"/>
</div>
<div style="float: right;">
    <label for="category_id"><strong>Category</strong></label>
    <select name="category_id" style="width: 150px;height: 18px;">
    <option value="0">.....</option>
    <?php    
    recu($category,0,-1,6);
    ?>
    </select>
</div>
<div style="clear: both;"></div>

    <label for="intro"><strong>Intro news</strong></label>
    <textarea class="ckeditor" name="intro" id="intro" rows="10"></textarea>
    <label for="intro"><strong>content news</strong></label>
    <textarea class="ckeditor" name="content" id="content" rows="15"></textarea>

<input type="submit" name="submit" value="postnews"/>
</form>
</div>
<div id="webpage"></div>
</body>
